package com.zhengke.service.bbfx;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhengke.common.dao.CommonDao;
import com.zhengke.common.object.Result;
import com.zhengke.pojo.MemberStat;

/**  

* 创建时间：2020年1月6日 下午2:33:31 

* 项目名称：tvmallbs  

* @author 王东科

* @version 1.0     

* 文件名称：MemberStatServiceImpl.java  

* 类说明：  

*/
@Service
public class MemberStatServiceImpl implements MemberStatService{

	@Autowired
	private CommonDao commonDao;
	
	/**
	 * 查询会员下单信息
	 * @param startTime
	 * @param endTime
	 * @param pageNum
	 * @param size
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Result queryMember(String startTime, String endTime, int pageNum, int size) throws Exception {
		Map<String,String> param = new HashMap<String,String>();
		param.put("startTime", startTime);
		param.put("endTime", endTime);
		
		PageHelper.startPage(pageNum, size, true);
		
		List<MemberStat> list = (List<MemberStat>) commonDao.findForList("memberStatMapper.queryMember", param);
		PageInfo<MemberStat> pageInfo = new PageInfo<MemberStat>(list);
		Result rs = new Result();
		rs.setCode("0");
		rs.setCount(pageInfo.getTotal());
		rs.setData(list);
		return rs;
	}
	/**
	 * 查询会员下单数总计
	 * @param startTime
	 * @param endTime
	 * @return
	 * @throws Exception
	 */
	@Override
	public MemberStat queryMemberNum(String startTime, String endTime) throws Exception {
		Map<String,String> param = new HashMap<String,String>();
		param.put("startTime", startTime);
		param.put("endTime", endTime);
		
		MemberStat memberStat = (MemberStat) commonDao.findForObject("memberStatMapper.queryMemberNum", param);
		System.out.println("======================>"+memberStat);
		return memberStat;
	}
	/**
	 * 查询日下单信息
	 * @param startTime
	 * @param endTime
	 * @param pageNum
	 * @param size
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Result queryDayOrder(String startTime, String endTime, int pageNum, int size) throws Exception {
		Map<String,String> param = new HashMap<String,String>();
		param.put("startTime", startTime);
		param.put("endTime", endTime);

		PageHelper.startPage(pageNum, size, true);

		List<MemberStat> list = (List<MemberStat>) commonDao.findForList("memberStatMapper.queryDayOrder", param);
		PageInfo<MemberStat> pageInfo = new PageInfo<MemberStat>(list);
		Result rs = new Result();
		rs.setCode("0");
		rs.setCount(pageInfo.getTotal());
		rs.setData(list);
		return rs;
	}

}
